//
//  BlipURL.m
//  blipTest
//
//  Created by dawid on 08-12-12.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "BlipURL.h"
#import "RegexKitLite.h"
//#include <RegexKit/NSString.h>

@implementation NSURL (BlipInit)
+(NSURL*)BLP_initWithRelativePath:(NSString*)relativePath
{
	NSString *urlString = [@"http://api.blip.pl" stringByAppendingPathComponent:relativePath];
	return [NSURL URLWithString:urlString];
}
+(NSURL*)BLP_initWithURL:(NSString*)url
{
	return [NSURL URLWithString:url];
}

+(NSURL*)BLP_initWithGetUpdatesUrl:(NSString*)sinceUpdate
{
	NSString *urlString;
  if ([sinceUpdate isKindOfClass:[NSNumber class]]) {
    sinceUpdate = [((NSNumber*)sinceUpdate) stringValue];
  }
	if ([sinceUpdate isMatchedByRegex:@"^0$"] == YES){

		urlString = [NSString stringWithFormat:@"http://api.blip.pl/dashboard?inlcude=pictures,user,recipient"];
	}
	else
	{
	 	urlString = [NSString stringWithFormat:@"http://api.blip.pl/dashboard/since/%@?inlcude=pictures,user,recipient", sinceUpdate];
	}
	return [NSURL URLWithString:urlString];
}
+(NSURL*)BLP_initWithUpdateMessageUrl
{
 	NSString *urlString = [NSString stringWithFormat:@"http://api.blip.pl/updates"];
	return [NSURL URLWithString:urlString];
}
+(NSURL*)BLP_initWithSubscriptions
{
 	NSString *urlString = [NSString stringWithFormat:@"http://api.blip.pl/subscriptions/from"];
	return [NSURL URLWithString:urlString];
}
+(NSURL*)BLP_initWithDirectedMessageUrl
{
 	NSString *urlString = [NSString stringWithFormat:@"http://api.blip.pl/directed_messages"];
	return [NSURL URLWithString:urlString];
}
+(NSURL*)BLP_initWithPrivateMessageUrl
{
 	NSString *urlString = [NSString stringWithFormat:@"http://api.blip.pl/private_messages"];
	return [NSURL URLWithString:urlString];
}
+(NSURL*)BLP_initWithExtendedUpdateforMessageId:(NSString*)msgId
{
 	NSString *urlString = [NSString stringWithFormat:@"http://api.blip.pl/updates/%@?include=user,pictures,user[avatar]", msgId];
	return [NSURL URLWithString:urlString];
}
+(NSURL*)BLP_initWithExtendedDirectedforMessageId:(NSString*)msgId
{
 	NSString *urlString = [NSString stringWithFormat:@"http://api.blip.pl/directed_messages/%@?include=user,pictures,user[avatar],recipient,recipient[avatar]", msgId];
	return [NSURL URLWithString:urlString];
}
+(NSURL*)BLP_initWithExtendedPrivateforMessageId:(NSString*)msgId
{
 	NSString *urlString = [NSString stringWithFormat:@"http://api.blip.pl/private_messages/%@?include=user,pictures,user[avatar],recipient,recipient[avatar]", msgId];
	return [NSURL URLWithString:urlString];
}
@end
